package com.ruoyi.charging.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.charging.domain.ChargingBillProgress;
import com.ruoyi.charging.service.IChargingBillProgressService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 充电进度Controller
 * 
 * @author ruoyi
 * @date 2023-09-06
 */
@RestController
@RequestMapping("/charge/progress")
public class ChargingBillProgressController extends BaseController
{
    @Autowired
    private IChargingBillProgressService chargingBillProgressService;

    /**
     * 查询充电进度列表
     */
    @PreAuthorize("@ss.hasPermi('charge:progress:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChargingBillProgress chargingBillProgress)
    {
        startPage();
        List<ChargingBillProgress> list = chargingBillProgressService.selectChargingBillProgressList(chargingBillProgress);
        return getDataTable(list);
    }

    /**
     * 导出充电进度列表
     */
    @PreAuthorize("@ss.hasPermi('charge:progress:export')")
    @Log(title = "充电进度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChargingBillProgress chargingBillProgress)
    {
        List<ChargingBillProgress> list = chargingBillProgressService.selectChargingBillProgressList(chargingBillProgress);
        ExcelUtil<ChargingBillProgress> util = new ExcelUtil<ChargingBillProgress>(ChargingBillProgress.class);
        util.exportExcel(response, list, "充电进度数据");
    }

    /**
     * 获取充电进度详细信息
     */
    @PreAuthorize("@ss.hasPermi('charge:progress:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(chargingBillProgressService.selectChargingBillProgressById(id));
    }

    /**
     * 新增充电进度
     */
    @PreAuthorize("@ss.hasPermi('charge:progress:add')")
    @Log(title = "充电进度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChargingBillProgress chargingBillProgress)
    {
        return toAjax(chargingBillProgressService.insertChargingBillProgress(chargingBillProgress));
    }

    /**
     * 修改充电进度
     */
    @PreAuthorize("@ss.hasPermi('charge:progress:edit')")
    @Log(title = "充电进度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChargingBillProgress chargingBillProgress)
    {
        return toAjax(chargingBillProgressService.updateChargingBillProgress(chargingBillProgress));
    }

    /**
     * 删除充电进度
     */
    @PreAuthorize("@ss.hasPermi('charge:progress:remove')")
    @Log(title = "充电进度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(chargingBillProgressService.deleteChargingBillProgressByIds(ids));
    }
}
